define(function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function() {
                return {
                    shop_info:{},
                    loading: 0,
                    page: 1,
                    status: 0,
                    lastpage: 0,
                    listData: [],
                    tag_id:0,
                    shop_id:0,
                    nodata:0,
                    order:'MallShopProvider.id desc'
                };
            },
            el: '#pageMyStoreList',
            created: function() {
                this.fetchData();
            },
            mounted: function() {
                    
                    if (this.mounted == 1) {
                        return;
                    }
                    
                    var that = this ;
                    app.pager("#pageMyStoreList",function(){
                       that.loadList();
                    });
                    this.mounted = 1;

            },
            methods: {
                fetchData: function() {
                    var _this = this;
                   
                    this.loadList();
                    
                },
               
                  loadList: function (reload) {
                    var that = this;

                    if (reload == 1) {
                      this.loading=0;
                      this.page=1;
                      this.lastpage=0;
                      this.listData=[];
                    }

                    var page = this.page;
                    if (this.loading == 1 || this.lastpage == 1) {
                      // console.log('12');
                      return;
                    }
                    this.loading = 1;
                    app.get("mall/shop/get", {
                      page: page,
                      limit: 100,
                      
                    }, function (res) {
                      that.loading = 0;
                      if (res.code != 200) {
                        app.alert(res.msg);
                        return;
                      }
                      if (res.data.list.length === 0) {
                        that.lastpage = 1;
                      }
                      that.page++;
                      that.listData=that.listData.concat(res.data.list); 
                      if(that.listData.length>0){
                        that.nodata=0;
                      } else{
                        that.nodata=1;
                      }
                    });

                  },
                
 
            }

        }).$mount('#app');
    };
    module.exports = controller;
});
